package com.beiyou.orderingsystemonweb.system.other;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

//应用域监听器，
//我打算用spring来实现了

public class InitServeltContext implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext servletContext = sce.getServletContext();
        System.out.println("得到项目的绝对路径:"+servletContext.getRealPath("/"));
//        D:\study\java企业开发\我的项目\orderingsystemonweb\target\orderingsystemonweb-1.0-SNAPSHOT\
        servletContext.setAttribute("imgPath",servletContext.getRealPath("/"));
    }
}
